<template>
<div>
  <div class="layout">
    <div class="register-container">
      <Subtitle :text="$t('registerConfirm.title')" />
      <IntelInput
          :label="$t('registerConfirm.inputLastName')"
          v-model="form.lastName"
          :placeholder="$t('registerConfirm.inputLastName')"
          class="register-input"
          :disabled="disabled"
          :focus="inputFocus"
          @blur="inputFocus=false"
      />
      <IntelInput
          :label="$t('registerConfirm.inputFirstName')"
          v-model="form.firstName"
          :placeholder="$t('registerConfirm.inputFirstName')"
          class="register-input"
          :disabled="disabled"
      />
      <div class="button-group m-t-80">
      <div class="primary-button m-r-16" @click="handleYesButtonClick">{{ $t('registerConfirm.buttonYes') }}</div>
      <div class="ghost-button" @click="handleNoButtonClick">{{ $t('registerConfirm.buttonNo') }}</div>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import IntelInput from "../../components/common/IntelInput";
import Subtitle from "../../components/common/Subtitle";
import Alert from "../../components/common/Alert";
import { getUserInfoAuto, updateUserInfo} from "../../api/service";

export default {
  name: "faq",
  components: {
    IntelInput,
    Subtitle,
    Alert
  },
  data () {
    return {
      alertShow: false,
      alertContent: '请勾选xxx',
      form: {
        lastName: null,
        firstName: null
      },
      disabled: true,
      inputFocus: false
    }
  },
  mounted() {
    const user = JSON.parse(localStorage.userInfo)
    this.form = {
      id: user.id,
      lastName: user.lastName,
      firstName: user.firstName,
      businessEmailAddress: user.businessEmailAddress
    }
  },
  methods: {
    handleYesButtonClick () {
      if (!this.disabled) {
        updateUserInfo(this.form).then(res => {
          console.log(res)
          if (res.data) {
            getUserInfoAuto()
            this.$router.push({
              path: this.$i18n.path('generalInfo')
            })
          }
        })
      } else {
        this.$router.push({
          path: this.$i18n.path('generalInfo')
        })
      }
    },
    handleNoButtonClick () {
      this.disabled = false
      this.inputFocus = true
    }
  }
}
</script>

<style scoped>
.register-input {
  margin-top: 16px;
}
.register-container {
  width: 800px;
  padding-top: 60px;
  padding-left: 120px;
  padding-bottom: 120px;
}
.create-text .title {
  font-weight: bold;
  font-size: 20px;
  color: #0068B5;
  padding-bottom: 18px;
}
.create-text .desc {
  font-size: 14px;
  color: #999999;
}

.create-text .desc a {
  color: #0068B5;
  text-decoration: none;
}

.primary-button {
  width: 146px;
  height: 36px;
  color: white;
  font-size: 14px;
  text-align: center;
  line-height: 36px;
  background: #0068B5;
  cursor: pointer;
  margin-top: 16px;
}
.ghost-button {
  width: 146px;
  height: 36px;
  font-size: 14px;
  text-align: center;
  line-height: 36px;
  color: #0068B5;
  border: 1px solid #0068B5;
  cursor: pointer;
  margin-top: 16px;
}

.m-t-80 {
  margin-top: 80px;
}
.m-r-16 {
  margin-right: 16px;
}

.agreement > input {
  margin-right: 8px;
}
.button-group {
  display: flex;
}
</style>
